package globalCode;

import java.util.HashMap;

public class UserData {

	private int userID;
	private String name;
	private TableHandler th;
	private boolean teacher;
	private HashMap<Integer, Integer> groupContivMap;
	
	public UserData(int uID, TableHandler t){
		userID = uID;
		th = t;
		groupContivMap = new HashMap<Integer, Integer>();
		setTeacher(th.isTeacher(userID));
		setName(th.getName(userID));
	}
	
	public boolean isTeacher() {
		return teacher;
	}
	public void setTeacher(boolean isTeacher) {
		this.teacher = isTeacher;
	}
	
	public int getGroupConnectivity(int id){
		if(!groupContivMap.containsKey(id)){
			groupContivMap.put(id, th.getGroupContiv(userID, id));
		}
			
		return groupContivMap.get(id);
	}

	public void setConnectivity(int group, int connectivity) {
		groupContivMap.put(group, connectivity);
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	public String toString(){
		String s = "";
		s+="User #:  "+userID+"\n";
		s+="Name:    "+name+"\n";
		s+="Teacher: "+teacher+"\n";
		s+="Group Connectivities:\n";
		for(Integer i: groupContivMap.keySet()){
			s+="    Group #"+i+": "+groupContivMap.get(i)+"\n";
		}
		return s;
	}
	
}
